<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>选择执行路径</title>
</head>
<body>
    <div class="form-group col-md-12" style="margin-top: 5px">
        <div class="col-md-9">
            <input type="text" class="form-control" id="searchCraftTxt" placeholder="请输入代码/名称 并以空格分开">
        </div>
        <div class="col-md-3">
            <button type="button" id="searchCraftBtn" class="btn btn-custom" style="width: 100%">搜索</button>
        </div>
    </div>
    <div class="bootstrap-table table col-md-12">
        <div class="table-responsive col-md-12" style="margin-top: 5px;">
            <table id="selectCraftResult" data-toggle="table"
                   data-click-to-select="true"
                   data-striped="true"
                   data-pagination="false"
                   data-row-style="rowStyle"
                   data-cell-style="cellStyle"
                   data-unique-id="id"
                   data-height="300">
                <thead>
                    <tr>
                        <th data-field="state" data-radio="true"></th>
                        <th data-field="id" data-visible="false"></th>
                        <th data-field="code">代码</th>
                        <th data-field="name">名称</th>
                        <th data-field="version">版本</th>
                        <th data-field="statusName">状态</th>
                    </tr>
                </thead>
            </table>
        </div>
    </div>
    <div class="form-group">
        <div class="col-md-12" style="margin-top:20px;">
            <div class="col-md-6" style="text-align: center">
                <button type="button" id="selectCraftconfirmBtn" class="btn btn-custom">确定</button>
            </div>
            <div class="col-md-6" style="text-align: center">
                <button type="button" id="selectCraftCancelBtn" class="btn btn-custom">取消</button>
            </div>
        </div>
    </div>
</body>
<script>
    // 相关地址
    var recipePathUrl = serverPath + "RecipePath/findRecipePathValid";

    $(function() {
        var searchTxt = $('#searchCraftTxt').val();
        FindData(searchTxt);
        // 搜索按钮 事件
        $("#searchCraftBtn").click(function() {
            var searchContain = $('#searchCraftTxt').val();
            FindData(searchContain);
        });
    });

    function FindData(str) {
        var datas = {'str':str};
        ibcpAjax.Select(recipePathUrl,datas,true,function(result){
            var data = result.data;
//            alert(JSON.stringify(data));
            $('#selectCraftResult').bootstrapTable('load', data);
            if(data.length >0) {
                //设置选中行
                $('#selectCraftResult').bootstrapTable('check', 0);
            }
        });
    };

    //确认按钮事件
    $("#selectCraftconfirmBtn").on('click', function () {
        var Path = $("#selectCraftResult").bootstrapTable("getSelections")[0];
        GetSelectPath(Path);
    });
</script>
</html>